package cn.huiyunche.base.service.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName: SensitiveDataReplacementUtils
 * @Description: 处理敏感数据不完全显示
 * @author: Aaron
 * @date: 2016年6月16日 上午9:44:51
 */
public class SensitiveDataReplacementUtils {

    /**
     * @param name
     * @return
     * @Title: replacementName
     * @Description: 覆盖姓名
     * @return: String
     */
    public static String replacementName(String name) {
        return (StringUtils.isBlank(name) != true && name.length() > 1) == true ? name.substring(0, 1) + "**" : null;
    }

    /**
     * @param phone
     * @return
     * @Title: replacementPhone
     * @Description: 覆盖手机号
     * @return: String
     */
    public static String replacementPhone(String phone) {
        return (StringUtils.isBlank(phone) != true && !(phone.length() < 11)) == true ? phone.substring(0, 3) + "****" + phone.substring(7, 11) : null;
    }

    /**
     * @param truckNo
     * @return
     * @Title: replacementTruckNo
     * @Description: 覆盖车牌号
     * @return: String
     */
    public static String replacementTruckNo(String truckNo) {
        return (StringUtils.isBlank(truckNo) != true && !(truckNo.length() < 7)) == true ? truckNo.substring(0, 5) + "**" : null;
    }
}
